Platform/Features/IonMonkey
From MozillaWiki
Please use "Edit with form" above to edit this page.
Status
Modern JIT Compiler for JavaScript (IonMonkey) | |
Stage | Landed |
Status | In progress |
Release target | Firefox 18 |
Health | OK |
Status note | ` |
Team
Product manager | Chris Blizzard |
Directly Responsible Individual | David Anderson |
Lead engineer | David Anderson, David Mandelin |
Security lead | ` |
Privacy lead | ` |
Localization lead | ` |
Accessibility lead | ` |
QA lead | Paul Silaghi |
UX lead | ` |
Product marketing lead | ` |
Operations lead | ` |
Additional members | ` |
Open issues/risks
`
Stage 1: Definition
1. Feature overview
IonMonkey is a new JIT for SpiderMonkey. Our goal is to implement a new compiler to enable many new JavaScript optimizations. In particular IonMonkey will feature much more organized and explicit data structures typical of advanced compilers. This goal of being clean and flexible will be extremely important for future optimization work and experimentation.
2. Users & use cases
Goals:
- Provide a backend that can match or beat the Trace JIT or Crankshaft in speed. Sub-goals:
- Fine-grained specialization and de-specialization.
- Integration with type inference.
- Clean, textbook IR so optimization passes can be separated and pipelined with well-known algorithms.
- Document and comment well so the implementation and its side effects can be easily understood.
- Recompilation, debugging, bailouts are all related - and should be solved up-front.
- First SpiderMonkey JIT that starts off with peer reviews!
- (Unknown feasibility) Act as a baseline compiler to replace JM2.
- Manage memory much better, in part to avoid range problems on x64.
Avoiding these:
- Aggressive stores. We should move state syncing to bailout points.
3. Dependencies
`
4. Requirements
- Does not regress correctness.
- Does not regress usability or bench-marketing performance.
Non-goals
`
Stage 2: Design
5. Functional specification
See bug 646923 for an experimental design in Python, and bug 650181 for IR plans.
See /RegisterAllocator for information on the register allocator interfaces.
6. User experience design
`
Stage 3: Planning
7. Implementation plan
`
8. Reviews
Security review
`
Privacy review
`
Localization review
`
Accessibility
`
Quality Assurance review
`
Operations review
`
Stage 4: Development
9. Implementation
Bailouts-
What: Bailouts are the heart of the optimizing compiler. When speculation fails (triggering a type, shape, overflow guard, etc), or C++ throws an exception, or needs to GC, we must be able to inspect the JIT frame, and if needed, reconstruct an interpreter frame. -
Dependencies:-
Register allocator -
Code Generator
-
-
Work involved:-
Implementing guards -
Snapshot building at guard points -
Bailout trampoline -
Frame reconstruction
-
-
Priority: Critical, blocks testing -
Time: 2-3 weeks -
Owner: dvander -
Status: DONE
-
- Calls out to C++
- What: Ability to call into C++ from JIT code.
- Dependencies: Bailouts
- Work involved:
- Macro assembler interface for managing calls.
- Ability to recover bailout information from within C++.
- C++ function calling convention (bake in JSCompartment, hold active ion cx?)
- Protocol for dealing with exceptions returned from C++ functions
- GC needs to walk Ion frames
- Priority: Very high
- Time: 4+ weeks
- Owner: npierron
- Property Access and Inline Caches
- What: Code to handle property access sites
- Dependencies: Bailouts, Calls out to C++
- Work involved:
- TypeOracle interface for learning about property accesses.
- Four cases of knowledge: Monomorphic, Polymorphic, Megamorphic, and Unknown (IC)
- Building JM-like IC structures into IM, solving old memory management problems like reset-on-GC, bloated IC structs
- Priority: High
- Time: 4-5 weeks?
- Owner: TBD
-
Function calls-
What: Ability to call other Ion or interpreter JS functions -
Dependencies: Bailouts -
Work involved:-
Handle monomorphic versus polymorphic calls (ICs). -
Handle arity mismatches. -
Modify trampolines and calling convention so frame reconstruction can restore nested frames.
-
-
Priority: High -
Time: 4+ weeks -
Status: Done, except for TI integration. -
Owner: sstangl
-
- Baseline Compiler
- What: A compiler that replaces JägerMonkey as an untyped and fast compiler.
- Dependencies: None, but needs close integration with ICs and type profiling
- Work involved: Explore problem space. Ideally, we want to use IonMonkey as the baseline compiler, but whether the compiler itself is fast enough is an open question. Similarly, the expense of taking and translating snapshots must be measured on scripts with a huge number of local variables.
- If IonMonkey is fast enough, we can just use it.
- If optimization passes are expensive, we can turn them off.
- If snapshots are too expensive, we can eliminate them and insert IR nodes to incrementally sync the stack.
- If IonMonkey is too slow, we can write a new baseline compiler and possibly consider it generating off MIR.
- Further work stems from this decision.
- Priority: High
- Time: 4 months
- Owner: TBD
- Type Feedback
- What: Feedback mechanism to inform IonMonkey about likely types of access sites.
- Dependencies: ICs
- Work involved:
- Explore problem space. Ideally we want to learn about types from ICs, using either previous IonMonkey runs or information from the baseline compiler (Ion or not). Therefore we should aim to share IC structures between all compilers.
- Implement a TypeOracle derivation that uses run-time profiling to inform IonMonkey.
- Priority: High
- Time: 4 weeks
- Owner: TBD
- Type Inference Integration
- What: Integrate IonMonkey's type system to Brian Hackett's type inference engine.
- Dependencies: None
- Work involved:
- Use Type Inference to determine specializations and inlining.
- Make a TypeOracle that uses inference results to inform IonMonkey.
- Support on-stack invalidation.
- Priority: High
- Time: 4 weeks
- Owner: dvander
-
Method Inlining-
What: Inline methods -
Dependencies: Bailouts, either profiling, ICs, or calls out to C++ -
Work involved:-
Some heuristic to determine whether methods should be inlined (this can be totally bogus, but maybe better to start with simple methods). -
Changing IonBuilder such that JSScripts bytecode parsing can be "stacked" so inner SSA graph is inlined. -
Change M/LSnapshots to be nested, so snapshots in an inner frame all point to the same outer snapshot. -
Change snapshot encoding and frame reconstruction to support inlining.
-
-
Priority: Medium -
Time: 3 weeks -
Owner: cdleary
-
-
On-Stack Replacement-
What: Jump into JIT code at loop headers, possibly by profiling off-thread. -
Work involved:-
Explore ways to monitor hotness of JIT code. -
Implement the ability to jump into Ion-compiled code at loop headers, possibly by inserting special OSR nodes in the IR.
-
-
Priority: Medium -
Time: 4 weeks -
Owner: sstangl
-
- ARM Port
- What: Port IonMonkey to ARM
- Work involved:
- Bootstrap ARM to x86 parity so both develop at the same time.
- Priority: High
- Time: 4 weeks
- Owner: mrosenberg
- Debugging
- What: Work with jsd/jsdbg2 or whatever debugging APIs are required.
- Dependencies: Bailouts, Baseline JIT
- Work involved:
- Deoptimizing from within C++
- Calling debug hooks/probes
- Implementing breakpoints, EvalInFrame
- Priority: Low (for now)
- Time: ???
- Owner: TBD
- Testing
- What: We should be testing everything - correctness, perf, memory.
- Dependencies: Bailouts
- Work involved:
- Making sure tbpl stays green, frequent merging from m-c.
- Breaking down memory, cpu time of each Ion pass.
- AWFY lines.
- Priority: High
- Time: Continuous
- Owner: everyone
Stage 5: Release
10. Landing criteria
`
Feature details
Priority | P1 |
Rank | 1 |
Theme / Goal | ` |
Roadmap | Platform |
Secondary roadmap | ` |
Feature list | Platform |
Project | Responsiveness |
Engineering team | JavaScript |
Team status notes
status | notes | |
Products | ` | ` |
Engineering | ` | ` |
Security | sec-review-unnecessary | ` |
Privacy | ` | ` |
Localization | ` | ` |
Accessibility | ` | ` |
Quality assurance | ` | ` |
User experience | ` | ` |
Product marketing | ` | ` |
Operations | ` | ` |